#include <iostream>
#include "include/Sales_item.h"

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

auto sum(int lo, int hi)
{
   int sum = 0;
   while (lo <= hi)
      sum += lo++;
   return sum;
}

void print_range(int lo, int hi)
{
   if (lo > hi)
   {
      print_range(hi, lo);
      return;
   }
   for (int i = lo; i != hi; ++i)
      cout << i << " ";
}

int main(int argc, char *argv[])
{
   // 输出
   std::cout << "Hello CPP!" << std::endl;
   std::cout << "Sum of 50 to 100 inclusive is: " << sum(50, 100) << std::endl;

   // 循环
   int i = 10;
   while (i >= 0)
   {
      std::cout << i-- << " " << std::endl;
   }

   int sum = 0;
   for (int val = 1; val <= 10; ++val)
   {
      sum += val;
      std::cout << "Sum of 1 to 10 inclusive is  " << sum << std::endl;
   }

   // Class
   // for (Sales_item item; cin >> item; cout << item << endl);
   Sales_item book;
   std::cin >> book;
   std::cout << book << std::endl;

   // test 0-201-70353-X 4 24.99

   // 输入输出
   int low = 0, high = 0;
   cout << "please input two integers:\n";
   cin >> low >> high;
   print_range(low, high);

   return 0;
}

int isbn()
{
   Sales_item item1, item2;
   cin >> item1 >> item2;
   if (item1.isbn() == item2.isbn())
      cout << item1 + item2 << endl;
   else
      cerr << "Different ISBN." << endl;
   return 0;
}